package cc.geguo.smartcan.controller;

import cc.geguo.smartcan.pojo.SysUser;
import cc.geguo.smartcan.service.SysUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Date;

@Controller
@RequestMapping("/sysUserController")
public class SysUserController {
	
	private static final Logger LOG = LoggerFactory.getLogger(SysUserController.class);
	
	@Resource
	private SysUserService sysUserService;
	
	@RequestMapping("/showUserToJspById/{userId}")
	public String showUser(Model model,@PathVariable("userId") Long userId){
		SysUser user = this.sysUserService.getById(userId);
		model.addAttribute("user", user);
		return "showUser";
	}
	
	@RequestMapping("/showUserToJSONById/{userId}")
	@ResponseBody
	public SysUser showUser(@PathVariable("userId") Long userId){
		SysUser user = sysUserService.getById(userId);
		return user;
	}

	@RequestMapping("/showEasyUI")
	public String showEasyUI(){
		LOG.debug("Load EasyUI..... webInfo 下没发直接访问");
		return "easyUI";
	}

	@RequestMapping("/showLogin")
	public String showLogin() {
		LOG.debug("Load EasyUI..... webInfo 下没发直接访问");
		return "login";
	}
	@RequestMapping("/showJson")
	public String showJson(){
		LOG.debug("Load Json..... webInfo 下没发直接访问");
		return "json";
	}
	
	@RequestMapping("/test-logback")
	@ResponseBody
	public Date testLogback(){
		LOG.trace("-----trace");
		LOG.debug("-----debug");
		LOG.info("-----info");
		LOG.warn("-----warn");
		LOG.error("-----error");
		return new Date();
	}
}
